package jcrosswords.domain;

import java.util.ArrayList;
import java.util.Collection;

public class Cell {
	
	private Coordinates coordinates;
	private Value value;
	private Collection<ClueResponseInstance> owners;
	private Collection<ClueResponseInstance> firstResponseOwners;
	
	public Cell(Coordinates coordinates, Value value) {
		setCoordinates(coordinates);
		setValue(value);
		owners = new ArrayList<ClueResponseInstance>();
		firstResponseOwners = new ArrayList<ClueResponseInstance>();
	}

	public Coordinates getCoordinates() {
		return coordinates;
	}
	
	private void setCoordinates(Coordinates coordinates) {
		if(coordinates == null) {
			throw new IllegalArgumentException();
		}
		this.coordinates = coordinates;
	}
	
	public Value getValue() {
		return value;
	}

	public void setValue(Value value) {
		this.value = value;
	}
	
	public Collection<ClueResponseInstance> getOwners() {
		return owners;
	}

	public void setOwners(Collection<ClueResponseInstance> owners) {
		if(owners == null) {
			throw new IllegalArgumentException();
		}
		this.owners = owners;
	}

	public Collection<ClueResponseInstance> getFirstResponseOwners() {
		return firstResponseOwners;
	}

	public void setFirstResponseOwners(
			Collection<ClueResponseInstance> firstResponseOwners) {
		if(firstResponseOwners == null) {
			throw new IllegalArgumentException();
		}
		this.firstResponseOwners = firstResponseOwners;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((coordinates == null) ? 0 : coordinates.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Cell other = (Cell) obj;
		if (coordinates == null) {
			if (other.coordinates != null)
				return false;
		} else if (!coordinates.equals(other.coordinates))
			return false;
		return true;
	}

	public String toString() {
		return coordinates + ": " + value;
	}



}